import {
  apiSearchGoods
} from "../../service/api/shop";

Page({
  data: {
    result: [],
    value: ''
  },

  //监听输入框
  onSearch: function (e) {
    var value = e.detail;
    if (value == "") {
      wx.showToast({
        title: '请输入文字',
        icon: "error"
      })
      this.setData({
        value: '',
        result: []
      })
    } else {
      this.setData({
        value: value
      })
      //调用接口
      apiSearchGoods({
        name: e.detail
      }).then(res => {
        this.setData({
          result: res.data
        })
      })
    }
  },

})